From: Florian Müllner Date: Sat, 29 Nov 2014 13:37:19 +0000 (+0000) Subject: main: Add support for -high-contrast theme variants X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1952 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f4cc3327e8694764d339abe6af2e757620409d5f;p=gnome-shell.git main: Add support for -high-contrast theme variants While the default Shell style is fairly decent with regard to accessibility requirements, having the ability to tweak certain aspects where the regular style works less well is still useful. For this purpose, try to load a -high-contrast theme variant of the default stylesheet when a high-contrast theme is requested (as determined by the GTK+ theme name). https://bugzilla.gnome.org/show_bug.cgi?id=740447 --- diff --git a/js/ui/main.js b/js/ui/main.js index 36d759169..0b22a368d 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -4,6 +4,7 @@ const Clutter = imports.gi.Clutter; const Gdk = imports.gi.Gdk; const Gio = imports.gi.Gio; const GLib = imports.gi.GLib; +const Gtk = imports.gi.Gtk; const Lang = imports.lang; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; @@ -75,7 +76,8 @@ let _cssStylesheet = null; let _a11ySettings = null; function _sessionUpdated() { - _loadDefaultStylesheet(); + if (sessionMode.isPrimary) + _loadDefaultStylesheet(); wm.setCustomKeybindingHandler('panel-main-menu', Shell.KeyBindingMode.NORMAL | @@ -109,6 +111,8 @@ function start() { sessionMode = new SessionMode.SessionMode(); sessionMode.connect('updated', _sessionUpdated); + Gtk.Settings.get_default().connect('notify::gtk-theme-name', + _loadDefaultStylesheet); _initializeUI(); shellDBusService = new ShellDBus.GnomeShell(); @@ -225,24 +229,36 @@ function _initializeUI() { }); } -function _getDefaultStylesheet() { +function _getStylesheet(name) { let stylesheet; - stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + sessionMode.stylesheetName); + stylesheet = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/' + name); if (stylesheet.query_exists(null)) return stylesheet; - stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + sessionMode.stylesheetName); + stylesheet = Gio.File.new_for_path(global.datadir + '/theme/' + name); if (stylesheet.query_exists(null)) return stylesheet; return null; } -function _loadDefaultStylesheet() { - if (!sessionMode.isPrimary) - return; +function _getDefaultStylesheet() { + let stylesheet = null; + let name = sessionMode.stylesheetName; + // Look for a high-contrast variant first when using GTK+'s HighContrast + // theme + if (Gtk.Settings.get_default().gtk_theme_name == 'HighContrast') + stylesheet = _getStylesheet(name.replace('.css', '-high-contrast.css')); + + if (stylesheet == null) + stylesheet = _getStylesheet(sessionMode.stylesheetName); + + return stylesheet; +} + +function _loadDefaultStylesheet() { let stylesheet = _getDefaultStylesheet(); if (_defaultCssStylesheet && _defaultCssStylesheet.equal(stylesheet)) return;